package com.cb.kfc.service.impl;

import com.cb.kfc.dao.IProductDao;
import com.cb.kfc.domain.Product;
import com.cb.kfc.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class ProductServiceImpl implements IProductService {

    @Autowired
    private IProductDao productDao;


    @Override
    public List<Product> findAll() throws Exception {
        return productDao.findAll();
    }

    @Override
    public void save(Product product) throws Exception {
        productDao.save(product);
    }

    @Override
    /**
     * 获得会员的id，批量，或者单个删除会员种类
     */
    public Integer deleteProductById(String[] ids) {
        if(ids !=null && ids.length>0){
            Integer integer = productDao.delete(ids);
            return integer;
        }
        return 0;
    }

    @Override
    public Product findOne(String id) {
        Product product = productDao.findOne(id);
        return product;
    }

    //编辑单个会员类别
    @Override
    public void update(Product product) {
        productDao.update(product);
    }
}
